package com.cssl.job;
import com.cssl.service.SendSms;
import com.github.qcloudsms.SmsSingleSender;
import com.github.qcloudsms.SmsSingleSenderResult;
import com.hzj.pojo.OrderInfo;
import com.hzj.service.OrderInfoService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


public class MyJob implements Job {


    @Autowired
    private OrderInfoService ois;
    @Autowired
    private SendSms ss;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        int appid = 1400523533; //应用列表ID
        String appkey  = "ee86605acd18b15abb88c6074c346126";//应用列表key

        int templateId = 970441;//模板ID
        String smsSign = "豆你笑公众号";//签名内容
        try {
            List<OrderInfo> orderInfos = ois.patientTips();
            for(OrderInfo of: orderInfos){
                //System.out.println("ofofofofof"+of);
                String patientName = of.getPatientName();
                String phone = of.getPatientPhone();
                String[] params = {patientName};//短信中对应的内容
                SmsSingleSender ss = new SmsSingleSender(appid,appkey);
                //86代表国内
                SmsSingleSenderResult sr = ss.sendWithParam("86",phone,templateId,params,smsSign,"","");
                //打印发送信息
                System.out.println(sr);
            }
        }catch (Exception e){
            e.printStackTrace();
        }


    }
}
